import {
  Tree,
  DataSet,
} from 'choerodon-ui/pro';
import Record from 'choerodon-ui/pro/lib/data-set/Record';
import React, { useMemo } from 'react';
import treeDS from './treeDataSet';

const nodeRenderer = ({ record }: { record?: Record | null | undefined }):React.ReactNode => {
  return record!.get('text');
};

const treeBasic: React.FC = (): React.ReactElement => {

  const treeDatasSet: DataSet = useMemo(() => new DataSet(treeDS()), []);

  return (
    <Tree
      dataSet={treeDatasSet}
      checkable
      renderer={nodeRenderer}
    />
  );
};

export default treeBasic;